/*	Copyright 2007 - Xavier Baro (xbaro@cvc.uab.cat)

	This file is part of eapmlib.

    Eapmlib is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or any 
	later version.

    Eapmlib is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __CLASSENSEMBLE_H__
#define __CLASSENSEMBLE_H__

#include "EvolutiveLib.h"
#include "Classifier.h"
#include <vector>

namespace Evolutive {

	//! Defines a data type for the classifiers vector
	class EVOLUTIVELIB_API CClassifiersVector : public std::vector<CClassifier*>{};

	//! Class that codifies an ensemble of classifiers
	class EVOLUTIVELIB_API CClassEnsemble : public CClassifier
	{
		//! Methods
	public:
		//! Default constructor		
		CClassEnsemble(void);

		//! Default destructor
		virtual ~CClassEnsemble(void);

#ifdef USE_OPENCV
		//! Returns the class name (From base class)
		virtual string GetClassNameID(void) {return "CClassEnsemble";}

		//! Classify a given data (From base class)
		virtual double Apply(CData *InputData) = 0;		

		//! Returns a pointer to the data	
		CClassifier* GetClassifier(int Idx);

		//! Returns the number of stages
		int GetNumClassifiers(void);		

		//! Add a new classifier to the ensemble
		void AddClassifier(CClassifier *Classifier);

		//! Clear all the classifiers of the ensemble
		void Reset(void);

		//! Sets the feature parameters from a chromosome (from base class)
		virtual void SetFeatureParameters(CChromosome *C);

		//! Returns the feature parameters that defines the classifier (from base class)
		virtual void GetFeatureParameters(int &NumParameters,double **Parameters);

		//! Save or recover the data to/from a file (from base class)
		virtual void Serialize(std::fstream &fs,bool Saving);

#endif //USE_OPENCV

	protected:
							
		//! Attributes
	protected:				

		//! Vector of classifiers
		CClassifiersVector m_Classifiers;

	};	
}

#endif // __CLASSENSEMBLE_H__
